package com.summer.campussct.controller;


import com.summer.campussct.pojo.dto.RestResult;
import com.summer.campussct.service.ICampusOrShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "校园与店铺相关API")
@RestController
@RequestMapping("/campusOrShop")
public class CampusOrShopController {

    @Resource
    private ICampusOrShopService campusOrShopService;


    @ApiOperation("获取校园或店铺圈分类页数据")
    @GetMapping("listWithVehicle/{type}")
    public RestResult listWithVehicles(@PathVariable("type") int type){
        return campusOrShopService.listWithVehicles(type);
    }

    @ApiOperation("根据id获取校园或店铺详情")
    @GetMapping("getDesc/{id}")
    public RestResult getDesc(@PathVariable("id") int id){
        return RestResult.success(campusOrShopService.getDescById(id));
    }

    @ApiOperation("校园列表")
    @GetMapping("getCampusList")
    public RestResult getCampusList(){
        return campusOrShopService.getCampusList();
    }

    @ApiOperation("根据id获取学校或车商名")
    @GetMapping("getName/{id}")
    public RestResult getName(@PathVariable("id") int id){
        return campusOrShopService.getNameById(id);
    }
}
